package com.gc.server.entity;


import lombok.Setter;
import lombok.Getter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * 周计划实体
 * 表名 plan
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Mar 10 11:17:45 CST 2020
 */
@Setter
@Getter
public class PlanEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    //
    private Long id;
    //用户ID
    private Long userId;
    //开始日期
    private Date startDate;
    //起止时间
    Date[] startDates;
    //结束日期
    private Date endDate;
    //起止时间
    Date[] endDates;
    //创建时间
    private Date createTime;
    //起止时间
    Date[] createTimes;
    //审核人ID
    private Long adminId;
    //评审人名称
    private String adminName;
    //标题
    private String title;
    //年
    private Integer year;
    //周
    private Integer week;
    //总分
    private BigDecimal score;

    private Integer done;

    //平均分
    private BigDecimal avg;

    //获取平均分
    public BigDecimal getAvg() {
        if (done == null || done == 0 || score == null) {
            return BigDecimal.ZERO;
        } else {
            return score.divide(new BigDecimal(done),2, BigDecimal.ROUND_HALF_UP);
        }
    }

    public PlanEntity() {

    }


    // 日程
    private List<TodoEntity> items;

    /**
     * 新增周计划构造
     *
     * @param userId
     * @param startDate
     * @param endDate
     * @param createTime
     */
    public PlanEntity(Long userId, Date startDate, Date endDate, Date createTime, String title) {
        this.userId = userId;
        this.startDate = startDate;
        this.endDate = endDate;
        this.createTime = createTime;
        this.title = title;
    }

    public PlanEntity(Long userId, Date startDate, Date endDate, Date createTime, Integer year, Integer week) {
        this.userId = userId;
        this.startDate = startDate;
        this.endDate = endDate;
        this.createTime = createTime;
        this.year = year;
        this.week = week;
    }
}
